package com.twang.stock.controller.common;

import com.alibaba.fastjson.JSONObject;
import com.twang.stock.entity.DfcfBanKuaiMaoLiLv;
import com.twang.stock.entity.TodayQinXu;
import com.twang.stock.entity.ZhangTingBan;
import com.twang.stock.entity.ex.TodayQinXuEx;
import com.twang.stock.entity.ex.ZhangTingBanEx;
import com.twang.stock.redis.RedisUtil;
import com.twang.stock.service.TodayQinXuService;
import com.twang.stock.service.ZhangTingBanService;
import com.twang.stock.service.impl.TodayQinXuServiceImpl;
import com.twang.stock.service.impl.ZhangTingBanServiceImpl;
import com.twang.stock.utils.date.HolidayCopy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/")
@Slf4j
public class ZhangTingBanController {

    @Autowired
    private TodayQinXuService todayQinXuService;

    @Autowired
    private ZhangTingBanService zhangTingBanService;
    @Autowired
    private RedisUtil redisUtil;

    @RequestMapping(value = "/zhangData")
    public ModelAndView zhangData() throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        Object obj = redisUtil.get(ZhangTingBanServiceImpl.ZHANG_TING_BAN_DATA);
        List<DfcfBanKuaiMaoLiLv> dfcfBanKuaiMaoLiLvList;
        if (null == obj) {
            dfcfBanKuaiMaoLiLvList = zhangTingBanService.queryZhangTingBanNew();
        } else {
            dfcfBanKuaiMaoLiLvList = JSONObject.parseArray(obj.toString(), DfcfBanKuaiMaoLiLv.class);
        }
        modelAndView.addObject("todayChengJiao", dfcfBanKuaiMaoLiLvList);
        modelAndView.setViewName("zhangTingBanStockInfo");
        return modelAndView;
    }

    @RequestMapping(value = "/zhangTingBan")
    public ModelAndView zhangTingBan(Integer num) throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        //
        todayQinXuService.zhangTingBanQuery(modelAndView);
        modelAndView.setViewName("ZhangTingBan");
        return modelAndView;
    }

}
